package cn.dansj.common.request.annotation.http;

import cn.dansj.common.request.annotation.encrypt.EncryptResponseData;
import cn.dansj.common.request.annotation.logging.Nologging;
import cn.dansj.common.request.annotation.permission.Permission;
import cn.dansj.common.utils.enums.BooleanType;
import cn.dansj.common.utils.enums.UserType;
import org.springframework.core.annotation.AliasFor;
import org.springframework.web.bind.annotation.RequestMethod;

import java.lang.annotation.*;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@RequestMappingMethod(method = RequestMethod.POST)
@EncryptResponseData
@Permission
@Nologging
public @interface PostMethod {
    /**
     * Alias for {@link RequestMappingMethod#name}.
     */
    @AliasFor(annotation = RequestMappingMethod.class)
    String name() default "";

    /**
     * Alias for {@link RequestMappingMethod#value}.
     */
    @AliasFor(annotation = RequestMappingMethod.class)
    String[] value() default {};

    /**
     * Alias for {@link RequestMappingMethod#path}.
     */
    @AliasFor(annotation = RequestMappingMethod.class)
    String[] path() default {};

    /**
     * Alias for {@link RequestMappingMethod#params}.
     */
    @AliasFor(annotation = RequestMappingMethod.class)
    String[] params() default {};

    /**
     * Alias for {@link RequestMappingMethod#headers}.
     */
    @AliasFor(annotation = RequestMappingMethod.class)
    String[] headers() default {};

    /**
     * Alias for {@link RequestMappingMethod#consumes}.
     */
    @AliasFor(annotation = RequestMappingMethod.class)
    String[] consumes() default {};

    /**
     * Alias for {@link RequestMappingMethod#produces}.
     */
    @AliasFor(annotation = RequestMappingMethod.class)
    String[] produces() default {};

    /**
     * 返回值是否加密
     */
    @AliasFor(annotation = EncryptResponseData.class, value = "value")
    BooleanType encrypt() default BooleanType.UNSET;

    /**
     * 要加密的字段
     */
    @AliasFor(annotation = EncryptResponseData.class, value = "filed")
    String encryptField() default "data";

    /**
     * 接口权限白名单
     */
    @AliasFor(annotation = Permission.class, value = "value")
    BooleanType permission() default BooleanType.UNSET;

    /**
     * 接口权限用户类型
     */
    @AliasFor(annotation = Permission.class)
    UserType userType() default UserType.INHERITED;

    /**
     * 是否记录日志，默认记录
     */
    @AliasFor(annotation = Nologging.class, value = "value")
    BooleanType nologging() default BooleanType.UNSET;
}
